package com.cwj.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/hello-world")
public class HelloWorldController {

    @Autowired
    private Environment environment;

    @Value("${user.name}")
    private String userName;

    @RequestMapping("/welcome")
    public String welcome(@RequestParam String haha) {

        return "Hello,world!" + haha;
    }

    @RequestMapping("/username")
    public String userName() {
        return environment.getProperty("user.name") + "---" + userName;
    }

}
